package com.wanchuang.shengfubao.adapter;

import android.content.Context;
import android.graphics.Color;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.module.LoadMoreModule;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.wanchuang.shengfubao.R;
import com.wanchuang.shengfubao.help.GlideHelper;
import com.wanchuang.shengfubao.proto.Mystock;
import com.ruffian.library.widget.RTextView;

import java.util.List;

/**
 * 文件名 : ProgressAdapter
 * 创建者 : MangoWang
 * 创建日期 : 2019/11/25 11:50
 * 微信 : MangoWaWang
 * 邮箱 : 763482205@qq.com
 * 描述 : TODO
 */

public class AllowApplyAdapter extends BaseQuickAdapter<Mystock.get_sn_transfer_list.List, BaseViewHolder> implements LoadMoreModule {

    private String userID;

    public AllowApplyAdapter(Context context, List<Mystock.get_sn_transfer_list.List> dataList, String useId) {
        super(R.layout.item_allow_apply, dataList);
        userID = useId;
    }

    @Override
    protected void convert(BaseViewHolder helper, Mystock.get_sn_transfer_list.List item) {
        if (userID.equals(item.getApplyMemberId())) {
            helper.setText(R.id.tv_name, "向 " + item.getMemberName() + " 划拨");
        } else {
            helper.setText(R.id.tv_name, item.getApplyMemberName() + " 划入");
        }
        GlideHelper.INSTANCE.loadImage(helper.getView(R.id.iv_image), item.getLogo());
        helper.setText(R.id.tv_goods_name, item.getGoodsName() + "/ " + item.getNum() + "台")
                .setText(R.id.tv_time, item.getCreatedTimeDate())
                .setText(R.id.tv_word, item.getWord())
                .setTextColor(R.id.tv_word, Color.parseColor(item.getColour()));
        RTextView textView = helper.getView(R.id.tv_status);
        String des = "";
        String color = "#FF72A05B";
        switch (item.getState()) {
            case "0":
                color = "#FF72A05B";
                switch (item.getWho()) {
                    case "0":
                        des = "待" + item.getMemberName() + "审核";
                        break;
                    case "1":
                        des = "待审核";
                        break;
                    case "2":
                        des = "待伙伴审核";
                        break;
                }
                break;
            case "1":
                color = "#FF1E79EB";
                switch (item.getWho()) {
                    case "0":
                        des = item.getMemberName() + "已同意";
                        break;
                    case "1":
                        des = "我已同意";
                        break;
                    case "2":
                        des = "伙伴已同意";
                        break;
                }
                break;
            case "2":
                color = "#FF9AAFAC";
                switch (item.getWho()) {
                    case "0":
                        des = item.getMemberName() + "已拒绝";
                        break;
                    case "1":
                        des = "我已拒绝";
                        break;
                    case "2":
                        des = "伙伴已拒绝";
                        break;
                }
                break;
            case "3":
                color = "#FF23BAB5";
                switch (item.getWho()) {
                    case "0":
                        des = item.getApplyMemberName()+"已撤回";
                        break;
                    case "1":

                        des = "我已撤回";
                        break;
                    case "2":
                        des = "伙伴已撤回";
                        break;
                }
                break;
        }
        textView.setText(des);
        textView.getHelper().setBackgroundColorNormal(Color.parseColor(color));
    }
}